package org.example.modules.user.controller;

import com.alibaba.fastjson2.JSONObject;
import lombok.extern.slf4j.Slf4j;
import org.example.common.utils.ThreadLocalUtil;
import org.example.modules.user.common.Commsult;
import org.example.modules.user.entry.User;
import org.example.modules.user.entry.vo.InfoDetailsVo;
import org.example.modules.user.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Description UserController
 * @Author xiaotian
 * @Date 2025-04-24
 */
@RestController
@Slf4j
@RequestMapping("/wxApi/wxUser")
public class UserController {

    @Autowired
    private UserService userService;

    @GetMapping("/getUserInfo")
    public Commsult<User> getUserInfoByUserName(){
        if(ThreadLocalUtil.getUserId()==null){
            return Commsult.fail(601,"登录过期请重新登录");
        }
        return Commsult.success(userService.getUserInfoByUserName(ThreadLocalUtil.getUserId()));
    }
    @PostMapping("/InfoDetails")
    private Commsult<InfoDetailsVo> getUserInfo(@RequestBody JSONObject data){
        return Commsult.success(userService.getUserInfo(data));
    }
}
